<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vuejs测试</title>
    <script src="vue/vue.js"></script>
</head>
<body>
<div id="app">
    <input type="text" v-model="message">
    <hr><br>
    <input type="text" v-model="person.name"><br>
    <input type="text" v-model="person.age">
    <button v-on:click="person.age++">+</button>
    <br>
    <h2>
        姓名为:{{person.name}}+年龄为:{{person.age}}
    </h2>

</div>
<script type="text/javascript">
    let app = new Vue({
        el: "#app",
        data: {
            message: "消息",
            person:{"name":"张三","age":13}
        },
        watch:{
            message(newValue,oldValue){
                console.log("新值:"+newValue+";旧值:"+oldValue);
            },
            person:{
                //开启深度监控,监控对象属性的变化
                deep:true,
                handler(obj){
                    console.log("name="+obj.name+";age="+obj.age);
                }
            }
        }

    });
</script>
</body>
</html>